/**
 * @file {目检 工站的flaw_filter model}
 */
 'use strict'

 const { DataTypes, Model, Op } = require('../../../azeroth').sequelize;
 const {flawFilterInitData} = require('../common/init_data');
 class FlawFilterMujian extends Model { }

  const initFlawFilterData = (sequelize_aim) => {
    FlawFilterMujian.init(
         ...flawFilterInitData,
         {
             freezeTableName: true,
             sequelize: sequelize_aim,
             modelName: 'flaw_filter',
             timestamps: false
         }
    )
  }
  FlawFilterMujian.getMaxIdfromDb = async () => {
      let sql = 'select max(id) as id from flaw_filter';
      let res = await sequelize_aim.query(sql, { type: sequelize_aim.QueryTypes.SELECT });
      return res[0].id ? res[0].id : 0;
  }
 /**
  *上传到产线flaw_filter 表
  * @param {Object} data 转换后上传的数据对象
  */
  FlawFilterMujian.uploadPolInfo = async (data) => {
     let res = await FlawFilterMujian.bulkCreate(data, {ignoreDuplicates : true});
     return res;
 }

 module.exports = {
    initFlawFilterData,
    FlawFilterMujian
 };